
import Modal from './Modal';

class IosConfirm {
    constructor() {
      this.onOk = null;

      this.show = this.show.bind(this);        //将show的事件绑定到父级元素，从而获取里面的数据（跳出函数限制）
      this.bindOk = this.bindOk.bind(this);
    }

    bindOk(fn) {
      this.onOk = fn;
    }

    show(title) {
		    const _this = this;

        Modal.show3(title,  {

            onOk: function($c) {
              this.hide();
              if (_this.onOk) {
                _this.onOk();
                _this.onOk = null;
              }
            },
            onCancel: function($c) {
              if (_this.onOk) {
                _this.onOk = null;
              }
            }
        });
    }
}

export default new IosConfirm();
